import { ref, computed} from "vue";
import { defineStore } from "pinia";
import axios from "axios";

export const jokeStore = defineStore('joke', ()=>{
  // 状态变量
  const joke = ref("狐狸很容易摔跤，因为它狡猾");

  // 刷新笑话
  const refreshJoke = async ()=>{
    // setTimeout(()=>{
    //   joke.value = "一个心值多少钱？一个亿，一心一亿";
    // }, 1000)
    const res = await axios.get("https://api-vue-base.itheima.net/api/joke");
    joke.value = res.data;
  }

  return {joke, refreshJoke}
})
